package com.example.leetcode.tree;

import com.example.leetcode.tree.common.TreeNode;
import com.example.leetcode.tree.common.TreeUtils;

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 * int val;
 * TreeNode left;
 * TreeNode right;
 * TreeNode() {}
 * TreeNode(int val) { this.val = val; }
 * TreeNode(int val, TreeNode left, TreeNode right) {
 * this.val = val;
 * this.left = left;
 * this.right = right;
 * }
 * }
 */
class Solution572 {
    public boolean isSubtree(TreeNode root, TreeNode subRoot) {
        return TreeUtils.isSubtree(root, subRoot);

    }
}

public class leetcode572 {
    public static void main(String[] args) {
        Solution572 solution572 = new Solution572();
        Integer[] nums = {3, 4, 5, 1, 2};
        Integer[] nums1 = {4, 1, 2};
        test572(solution572, nums, nums1);
    }

    private static void test572(Solution572 solution572, Integer[] nums, Integer[] nums1) {
        TreeNode root = TreeUtils.generateLeetcodeTree(nums);
        TreeNode root1 = TreeUtils.generateLeetcodeTree(nums1);
        System.out.println(solution572.isSubtree(root, root1));
    }
}
